/*
 * @Author: Dufen~123 dufen.0
 * @Date: 2024-11-26 15:28:40
 * @LastEditors: Dufen~123 dufen.0
 * @LastEditTime: 2024-11-29 14:36:19
 * @FilePath: \my-app\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Main from '../pages/main'
import Home from '../pages/home'
import pageOne from '../pages/other/pageOne'
import pageTwo from '../pages/other/pageTwo'
import Mall from '../pages/mall'
import User from '../pages/user'
import Login from '../pages/login'
import UseEffect  from '../pages/useEffect/useEffect'
import Echarts from "../pages/echarts"




import {
    createBrowserRouter, //这是一个方法
    Navigate,//这是一个组件
  } from "react-router-dom";
import { Component } from 'react'
//routes是一个对象，后续作为方法createBrowserRouter的参数
  const routes =[
    {
        path:'/',
        Component:Main,//主路由
        children:[//子路由
            //重定向，当访问/时跳转到home页面
            {
                path:'/',
                element:<Navigate to="/home" replace/>,
            },
            {
                path:'home',
                Component:Home,
            },
            {
                path:'mall/:id?',
                Component:Mall,
            },
            {
                path:'user',
                Component:User,
            },
            {
                path:'echarts',
                Component:Echarts,
            },
            {
                path:'other',
                children:[
                    {
                        path:'pageOne',
                        Component:pageOne
                    },
                    {
                        path:'pageTwo',
                        Component:pageTwo
                    },
                    {
                        path:'UseEffect',
                        Component:UseEffect
                    },
                ]
            },
        ]
  },
  {
    path:'/login',
    Component:Login
  }
]

export default createBrowserRouter(routes)